package org.jeecg.modules.workflow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.mybatis.query.LambdaQueryWrapperX;
import org.jeecg.common.workflow.vo.oa.BpmOALeavePageReqVO;
import org.jeecg.modules.workflow.entity.BpmOaLeave;

/**
 * OA 请假申请Mapper接口
 *
 * @author whnk
 * @date 2022-04-20
 */
public interface BpmOaLeaveMapper extends BaseMapper<BpmOaLeave>
{
    default IPage<BpmOaLeave> selectPage(String userId, BpmOALeavePageReqVO reqVO) {
        Page<BpmOaLeave> page = new Page<>(reqVO.getPageNum(), reqVO.getPageSize());
        return selectPage(page, new LambdaQueryWrapperX<BpmOaLeave>()
                .eqIfPresent(BpmOaLeave::getUserId, userId)
                .eqIfPresent(BpmOaLeave::getResult, reqVO.getResult())
                .eqIfPresent(BpmOaLeave::getType, reqVO.getType())
                .likeIfPresent(BpmOaLeave::getReason, reqVO.getReason())
                .betweenIfPresent(BpmOaLeave::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BpmOaLeave::getId));
    }
}
